//
//  SLActionSheet.m
//  CoolRollerSkating
//
//  Created by WSL on 15/11/20.
//  Copyright © 2015年 Coollang. All rights reserved.
//

#import "SLActionSheet.h"

@interface SLActionSheet ()

@property (weak, nonatomic) IBOutlet UIButton *firstSelectBtn;
@property (weak, nonatomic) IBOutlet UIButton *secondSelectBtn;
@property (weak, nonatomic) IBOutlet UIButton *cancelBtn;

@property (copy, nonatomic) ClickBlock clickBlock;


@end

@implementation SLActionSheet

- (instancetype)init{
    self = [[[NSBundle mainBundle] loadNibNamed:@"SLActionSheet" owner:nil options:nil] lastObject];
    if (self) {
        
    }
    return self;
}

- (instancetype)initWithFirstTitle:(NSString *)firstTitle
                       secondTitle:(NSString *)secondTitle
                       cancelTitle:(NSString *)cancelTitle
                          callback:(ClickBlock)block{
    self = [self init];
    if (self) {
        [self.firstSelectBtn setTitle:firstTitle forState:UIControlStateNormal];
        [self.secondSelectBtn setTitle:secondTitle forState:UIControlStateNormal];
        [self.cancelBtn setTitle:cancelTitle forState:UIControlStateNormal];
        self.clickBlock = block;
    }
    return self;
}


- (IBAction)ClickFirstBtn {
    self.clickBlock(ClickFirstEvent);
    [self hiddenView];
}

- (IBAction)clickSecondBtn {
    self.clickBlock(ClickSecondEvent);
    [self hiddenView];
}

- (IBAction)clickCancelBtn {
    self.clickBlock(ClickCancelEvent);
    [self hiddenView];

}

- (void)hiddenView{
    CGFloat width  = [UIScreen mainScreen].bounds.size.width;
    CGFloat height = [UIScreen mainScreen].bounds.size.height;
    [UIView animateWithDuration:0.2 animations:^{
        self.frame = CGRectMake(0, height, width, height - self.bounds.size.height);
    }];
}

@end
